<template>
  <div>
    <el-dialog :title="title" :close-on-click-modal="false" :visible.sync="visible" center fullscreen>
      <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
      <el-form :model="dataForm" ref="dataForm" label-width="120px">
        <el-form-item label="编辑别名">
          <el-input v-model="dataForm.alias"></el-input>
        </el-form-item>
        <el-form-item label="定制语句">
          <code-mirror :value="dataForm.sentence" @getCodeMirror="getCodeData"></code-mirror>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveData">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'
  // import { getAddFeeObj, addAddFeeObj, putAddFeeObj } from '@/api/eims/add-fee'

  import { getDataSetId, getDataSetOne } from '@/api/cboard/cboard'


  import CodeMirror from '../components/CodeMirror'   // 编辑器


  export default {
    props: ['title'],
    data () {
      return {
        visible: false,
        dataForm: {
          alias: '',
          sentence: ''
        }
      }
    },
    components: {
      CodeMirror
    },
    computed: {
      ...mapGetters(['bizData'])
    },
    methods: {
      init(aliasIndex) {
        this.visible = true
        this.aliasIndex = aliasIndex
        this.dataForm.alias = ''
        this.dataForm.sentence = ''
      },
      getCodeData(data){
        this.$set(this.dataForm, 'sentence', data)
      },
      saveData(){
        this.visible = false
        this.$emit('refreshData',{alias: this.dataForm.alias,index: this.aliasIndex})
      }
    }
  }
</script>
